<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>妙客邦生态商城</title>
  <link rel="stylesheet" href="/static/layui/css/layui.css">
  <link rel="stylesheet" href="/static/css/style.css">
  <script src="/static/layui/jquery.min.js"></script>
  <script src="/static/layui/jquery.pjax.js"></script>
  <script src="/static/layui/layui.js"></script>
  <script type="text/javascript" src="/static/admin/js/admin.js"></script>
  <script type="text/javascript" src="/static/js/xyl.js"></script>
  <script type="text/javascript" src="/static/js/tinymce/tinymce.min.js"></script> 
</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo layui-hide-xs layui-bg-black">妙客邦生态商城</div>
    <!-- 头部区域（可配合layui 已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <!-- 移动端显示 -->
      <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
        <i class="layui-icon layui-icon-spread-left"></i>
      </li>
      <li class="layui-nav-item layui-hide-xs"><a href="/store">首页</a></li>
      <!-- <li class="layui-nav-item layui-hide-xs"><a href="">nav 2</a></li>
      <li class="layui-nav-item layui-hide-xs"><a href="">nav 3</a></li>
      <li class="layui-nav-item">
        <a href="javascript:;">nav groups</a>
        <dl class="layui-nav-child">
          <dd><a href="">menu 11</a></dd>
          <dd><a href="">menu 22</a></dd>
          <dd><a href="">menu 33</a></dd>
        </dl>
      </li> -->
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item layui-hide layui-show-md-inline-block">
        <a href="javascript:;">
          <img src="{:session('avatar')}" class="layui-nav-img">
           {:session('nickname')}
        </a>
        <dl class="layui-nav-child">
          <dd><a href="javascript:;" id="me">修改个人资料</a></dd>
          <dd><a href="{:url('/store/auth/logout')}">退出登录</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
        <a href="javascript:;">
          <i class="layui-icon layui-icon-more-vertical"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree" lay-filter="test">
        {notempty name='menus'}
          {foreach $menus as $menu}
          <!-- layui-nav-itemed -->
            <li class="layui-nav-item">
              <a class="menu-item" href="{$menu.url}">{$menu.title}</a>
              <dl class="layui-nav-child">
                {notempty name="menu.children"}
                  {foreach $menu.children as $vo}
                      {notempty name='vo.display'}
                        {if $vo.selected==1}
                          <dd class="layui-this"><a class="menu-item" href="{$vo.url}">{$vo.title}</a></dd>
                        {else/}
                          <dd><a class="menu-item" href="{$vo.url}">{$vo.title}</a></dd>
                        {/if}
                      {/notempty}
                  {/foreach}
                {/notempty}
              </dl>
            </li>
          {/foreach}
        {/notempty}  
      </ul>
    </div>
  </div>
  <div class="layui-body" style="background-color: #f3f3f3;">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;" id="main">
        {__CONTENT__}
    </div>
  </div>
</div>
<script>

$('.layui-this').parents('li').addClass('layui-nav-itemed');

//$(document).pjax('a','#main');
//
//$(document).on('submit', 'form', function (event) {
//      $.pjax.submit(event, '#main');
//});

layui.use(['element', 'upload', 'util','form'], function(){
  var element = layui.element
  ,layer = layui.layer
  ,util = layui.util,form = layui.form;

  form.on('checkbox(parent)',function(data){
    selected(data.elem.checked);
  })

  function selected(checked){
    $('.son').each(function(){
      $(this).prop('checked',checked);
    });
    form.render('checkbox');
  }

  form.on('checkbox(son)',function(data){
    sonSelected();
  })

  function sonSelected(){
    let son = $('.son');
    let count = 0;
    son.each(function(){
      if($(this).prop('checked')){
        count++;
      }
    });

    $('#parent').prop('checked',son.length == count);
    form.render('checkbox');
  }

  $(document).on('pjax:success',function(data,status){
      form.render();
      let content = $(status).find('#content');
     
    
  })

  
  //头部事件

  $('#me').click(function(){
             layer.open({
             title:['修改资料'],  
             type:2,
             area:['600px','800px'],
             content: '/store/auth/me'
        })
  });

  util.event('lay-header-event', {
    //左侧菜单事件
    menuLeft: function(othis){
      layer.msg('展开左侧菜单的操作', {icon: 0});
    }
    ,menuRight: function(){
      layer.open({
        type: 1
        ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
        ,area: ['260px', '100%']
        ,offset: 'rt' //右上角
        ,anim: 5
        ,shadeClose: true
      });
    }
  });
  
});
</script>
</body>
</html>